#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main()
{
    int sockfd;
    struct sockaddr_in servaddr;

    sockfd = socket(PF_INET, SOCK_DGRAM, 0);

    bzero(&servaddr, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    servaddr.sin_port = htons(50001);

    bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));

    int size;
    char recvline[1024];
	struct sockaddr_in cliaddr;
	int len = sizeof(cliaddr);

    size = recvfrom(sockfd, recvline, 1024, 0, (struct sockaddr *)&cliaddr, &len);
	sendto(sockfd,recvline,size,0,(struct sockaddr *)&cliaddr,sizeof(cliaddr));

    printf("%s\n", recvline);

    close(sockfd);
}